<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@taglib uri="/WEB-INF/tld/pageutil.tld" prefix="pu"%>
<%@taglib uri="/WEB-INF/tld/pageable.tld" prefix="pageable"%>
<%@taglib uri="http://java.sun.com/jstl/core" prefix="c"%>
<%@taglib uri="http://java.sun.com/jstl/core_rt" prefix="c-rt"%>
<%@taglib uri="http://java.sun.com/jstl/fmt_rt" prefix="fmt-rt"%>
<c-rt:set var="tp" value="${pu:pageableTag('tpp', 10, 10)}"/>
<c-rt:if test="${empty param.keyword}">
	<c-rt:set var="results" value="${pu:queryByHql('from Question order by createDate desc', null, tp)}"/>
</c-rt:if>
<c-rt:if test="${!empty param.keyword}">
	<c-rt:set var="hql">
	from Question where description like ? and shortDesc like ? order by createDate desc
	</c-rt:set>
	<c-rt:set var="keyword">
	%${param.keyword }%
	</c-rt:set>
	<c-rt:set var="params" value="${pu:addToList('paras', keyword)}"/>
	<c-rt:set var="params" value="${pu:addToList('paras', keyword)}"/>
	<c-rt:set var="results" value="${pu:queryByHql(hql, params, tp)}"/>
</c-rt:if>
<br />
<h1>问题单管理

</h1>
<form name="workOrderForm" id="workOrderForm">
<table>
<tr>
<td>关键字:<input type="text" value="${param.keyword }" name="keyword"/></td><td><div class="f-link"><a href="javascript:;" id="cs">search</a></div></td>
</tr>
</table>
</form>
<div class="f-link"><a href="#" id="questionToAdd">建立</a></div>
<table class="tb-1" width="100%">
		<thead>
			<tr>
				<th></th>
				<th>状态</th>
				<th>会员</th>
				<th>channel</th>
				<th>类型</th>
				<th>短描述</th>
				<th>描述</th>
				<th>建立日期</th>
			</tr>
		</thead>
		<tbody>
			<c-rt:forEach items="${results}" var="result" varStatus="rows_index">
				<tr class="${rows_index.count % 2 == 0 ? 'bg-yl' : ''}">
					<td>
					<input type="button" value="编辑" onclick="doAR('<%=application.getContextPath() %>/cs/page.do?iamlazy=question&questionID=${result.id }', 'main')"/>
					</td>
					<td>
					${pu:menuOption('Question.status', pu:toString(result.status)).name }
					</td>
					<td>
					<c-rt:if test="${!empty result.memberId}">
					<c-rt:set var="member" value="${pu:get('com.yaodian100.ec.member.entity.Member', result.memberId)}"/>
					${member.name }
					</c-rt:if>
					</td>
					<td>${result.channel.title }</td>
					<td>${result.type.name }</td>
					<td>${result.shortDesc }</td>
					<td>${result.description}</td>
					<td><fmt-rt:formatDate value="${result.createDate }" pattern="yyyy/MM/dd HH:mm"/></td>
				</tr>
			</c-rt:forEach>
		</tbody>
	</table>
<c-rt:set var="url">
<%=application.getContextPath() %>/cs/page.do?iamlazy=list
</c-rt:set>
<pageable:Pageable url="${url}" escapeparams="iamlazy,AJAX,refreshZone" parameter="AJAX=true&refreshZone=main" formname="csForm" key="tpp"></pageable:Pageable>

<script>

$(document).ready(function(){
	$('#questionToAdd').click(function(){
		doAR('<%=application.getContextPath() %>/cs/page.do?iamlazy=selectType&AJAX=true&refreshZone=main', 'main');
	});
	$('#cs').click(function(){
		doAR('<%=application.getContextPath() %>/cs/page.do?iamlazy=list&AJAX=true&refreshZone=main', 'main', 'workOrderForm');
	});
	$('#workOrderForm').submit(function(){
		doAR('<%=application.getContextPath() %>/cs/page.do?iamlazy=list&AJAX=true&refreshZone=main', 'main', 'workOrderForm');
	});
});
</script>